home *** CD-ROM | disk | FTP | other *** search
- /* Code to keep an INIT file opened at boot time around all the time, à la
- SuitCase II et al. */
-
- #include <types.h>
- #include <memory.h>
- #include <sysequ.h>
- #include <osutils.h>
- #include <traps.h>
-
- typedef struct _res_map res_map;
- typedef struct _res_map *res_map_ptr;
- typedef struct _res_map **res_map_handle;
-
- struct _res_map {
- long void1; /* Reserved */
- long void2; /* Reserved */
- long void3; /* Reserved */
- long void4; /* Reserved */
- res_map_handle next_map; /* Handle of next resource map */
- short refNum; /* fRefNum for this file */
- short fileAttrs; /* Resource file attributes for this file */
- short tlOffset; /* Type List Offset from beginning of map */
- short nlOffset; /* Name List Offset from beginning of map */
- };
-
- pascal void FakeCloseResFile(refNum)
- short refNum;
- #pragma unused (refNum);
- {
- res_map_handle *legal_TopMapHndl = TopMapHndl;
- long *legal_Scratch8 = Scratch8;
- res_map_handle the_map;
-
- the_map = *((res_map_handle *)TopMapHndl);
- *legal_TopMapHndl = (*the_map)->next_map;
- DisposHandle((Handle)the_map);
- NSetTrapAddress(*legal_Scratch8, _CloseResFile, ToolTrap);
- }
-
- keep_me_around(void)
- {
- THz saved_zone;
- res_map_handle map_copy;
- res_map_handle curr_map;
- res_map_handle *legal_TopMapHndl = TopMapHndl;
- long *legal_Scratch8 = Scratch8;
-
- /* The next few lines make a copy of the top resource map in the System Heap */
- saved_zone = GetZone();
- SetZone(*(THz *)SysZone);
- map_copy = *((res_map_handle *)TopMapHndl);
- HandToHand((Handle *)&map_copy);
- SetZone(saved_zone);
- /* The next few lines wipe out the original handle and stick the copy at the END
- of the resource chain. */
- curr_map = (*map_copy)->next_map;
- while (curr_map != *(res_map_handle *)SysMapHndl)
- curr_map = (*curr_map)->next_map;
- (*map_copy)->next_map = (*curr_map)->next_map;
- (*curr_map)->next_map = map_copy;
- *legal_Scratch8 = NGetTrapAddress(_CloseResFile, ToolTrap);
- NSetTrapAddress((long)&FakeCloseResFile, _CloseResFile, ToolTrap);
- }
-
-